package com.wqm.cn.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
/**
*
*  @author wqm
*/
public class USERROLE implements Serializable {

    private static final long serialVersionUID = 1607691466384L;


    /**
    * 用户ID
    * isNullAble:0
    */
    private Integer uSERID;

    /**
    * 角色ID
    * isNullAble:0
    */
    private Integer rOLEID;

    /**
    * 描述
    * isNullAble:1
    */
    private String DESCRIPTION;


    public void setUSERID(Integer uSERID){this.uSERID = uSERID;}

    public Integer getUSERID(){return this.uSERID;}

    public void setROLEID(Integer rOLEID){this.rOLEID = rOLEID;}

    public Integer getROLEID(){return this.rOLEID;}

    public void setDESCRIPTION(String DESCRIPTION){this.DESCRIPTION = DESCRIPTION;}

    public String getDESCRIPTION(){return this.DESCRIPTION;}
    @Override
    public String toString() {
        return "USERROLE{" +
                "uSERID='" + uSERID + '\'' +
                "rOLEID='" + rOLEID + '\'' +
                "DESCRIPTION='" + DESCRIPTION + '\'' +
            '}';
    }

    public static Builder Build(){return new Builder();}

    public static ConditionBuilder ConditionBuild(){return new ConditionBuilder();}

    public static UpdateBuilder UpdateBuild(){return new UpdateBuilder();}

    public static QueryBuilder QueryBuild(){return new QueryBuilder();}

    public static class UpdateBuilder {

        private USERROLE set;

        private ConditionBuilder where;

        public UpdateBuilder set(USERROLE set){
            this.set = set;
            return this;
        }

        public USERROLE getSet(){
            return this.set;
        }

        public UpdateBuilder where(ConditionBuilder where){
            this.where = where;
            return this;
        }

        public ConditionBuilder getWhere(){
            return this.where;
        }

        public UpdateBuilder build(){
            return this;
        }
    }

    public static class QueryBuilder extends USERROLE{
        /**
        * 需要返回的列
        */
        private Map<String,Object> fetchFields;

        public Map<String,Object> getFetchFields(){return this.fetchFields;}

        private List<Integer> uSERIDList;

        public List<Integer> getUSERIDList(){return this.uSERIDList;}

        private Integer uSERIDSt;

        private Integer uSERIDEd;

        public Integer getUSERIDSt(){return this.uSERIDSt;}

        public Integer getUSERIDEd(){return this.uSERIDEd;}

        private List<Integer> rOLEIDList;

        public List<Integer> getROLEIDList(){return this.rOLEIDList;}

        private Integer rOLEIDSt;

        private Integer rOLEIDEd;

        public Integer getROLEIDSt(){return this.rOLEIDSt;}

        public Integer getROLEIDEd(){return this.rOLEIDEd;}

        private List<String> DESCRIPTIONList;

        public List<String> getDESCRIPTIONList(){return this.DESCRIPTIONList;}


        private List<String> fuzzyDESCRIPTION;

        public List<String> getFuzzyDESCRIPTION(){return this.fuzzyDESCRIPTION;}

        private List<String> rightFuzzyDESCRIPTION;

        public List<String> getRightFuzzyDESCRIPTION(){return this.rightFuzzyDESCRIPTION;}
        private QueryBuilder (){
            this.fetchFields = new HashMap<>();
        }

        public QueryBuilder uSERIDBetWeen(Integer uSERIDSt,Integer uSERIDEd){
            this.uSERIDSt = uSERIDSt;
            this.uSERIDEd = uSERIDEd;
            return this;
        }

        public QueryBuilder uSERIDGreaterEqThan(Integer uSERIDSt){
            this.uSERIDSt = uSERIDSt;
            return this;
        }
        public QueryBuilder uSERIDLessEqThan(Integer uSERIDEd){
            this.uSERIDEd = uSERIDEd;
            return this;
        }


        public QueryBuilder uSERID(Integer uSERID){
            setUSERID(uSERID);
            return this;
        }

        public QueryBuilder uSERIDList(Integer ... uSERID){
            this.uSERIDList = solveNullList(uSERID);
            return this;
        }

        public QueryBuilder uSERIDList(List<Integer> uSERID){
            this.uSERIDList = uSERID;
            return this;
        }

        public QueryBuilder fetchUSERID(){
            setFetchFields("fetchFields","uSERID");
            return this;
        }

        public QueryBuilder excludeUSERID(){
            setFetchFields("excludeFields","uSERID");
            return this;
        }

        public QueryBuilder rOLEIDBetWeen(Integer rOLEIDSt,Integer rOLEIDEd){
            this.rOLEIDSt = rOLEIDSt;
            this.rOLEIDEd = rOLEIDEd;
            return this;
        }

        public QueryBuilder rOLEIDGreaterEqThan(Integer rOLEIDSt){
            this.rOLEIDSt = rOLEIDSt;
            return this;
        }
        public QueryBuilder rOLEIDLessEqThan(Integer rOLEIDEd){
            this.rOLEIDEd = rOLEIDEd;
            return this;
        }


        public QueryBuilder rOLEID(Integer rOLEID){
            setROLEID(rOLEID);
            return this;
        }

        public QueryBuilder rOLEIDList(Integer ... rOLEID){
            this.rOLEIDList = solveNullList(rOLEID);
            return this;
        }

        public QueryBuilder rOLEIDList(List<Integer> rOLEID){
            this.rOLEIDList = rOLEID;
            return this;
        }

        public QueryBuilder fetchROLEID(){
            setFetchFields("fetchFields","rOLEID");
            return this;
        }

        public QueryBuilder excludeROLEID(){
            setFetchFields("excludeFields","rOLEID");
            return this;
        }

        public QueryBuilder fuzzyDESCRIPTION (List<String> fuzzyDESCRIPTION){
            this.fuzzyDESCRIPTION = fuzzyDESCRIPTION;
            return this;
        }

        public QueryBuilder fuzzyDESCRIPTION (String ... fuzzyDESCRIPTION){
            this.fuzzyDESCRIPTION = solveNullList(fuzzyDESCRIPTION);
            return this;
        }

        public QueryBuilder rightFuzzyDESCRIPTION (List<String> rightFuzzyDESCRIPTION){
            this.rightFuzzyDESCRIPTION = rightFuzzyDESCRIPTION;
            return this;
        }

        public QueryBuilder rightFuzzyDESCRIPTION (String ... rightFuzzyDESCRIPTION){
            this.rightFuzzyDESCRIPTION = solveNullList(rightFuzzyDESCRIPTION);
            return this;
        }

        public QueryBuilder DESCRIPTION(String DESCRIPTION){
            setDESCRIPTION(DESCRIPTION);
            return this;
        }

        public QueryBuilder DESCRIPTIONList(String ... DESCRIPTION){
            this.DESCRIPTIONList = solveNullList(DESCRIPTION);
            return this;
        }

        public QueryBuilder DESCRIPTIONList(List<String> DESCRIPTION){
            this.DESCRIPTIONList = DESCRIPTION;
            return this;
        }

        public QueryBuilder fetchDESCRIPTION(){
            setFetchFields("fetchFields","DESCRIPTION");
            return this;
        }

        public QueryBuilder excludeDESCRIPTION(){
            setFetchFields("excludeFields","DESCRIPTION");
            return this;
        }
        private <T>List<T> solveNullList(T ... objs){
            if (objs != null){
            List<T> list = new ArrayList<>();
                for (T item : objs){
                    if (item != null){
                        list.add(item);
                    }
                }
                return list;
            }
            return null;
        }

        public QueryBuilder fetchAll(){
            this.fetchFields.put("AllFields",true);
            return this;
        }

        public QueryBuilder addField(String ... fields){
            List<String> list = new ArrayList<>();
            if (fields != null){
                for (String field : fields){
                    list.add(field);
                }
            }
            this.fetchFields.put("otherFields",list);
            return this;
        }
        @SuppressWarnings("unchecked")
        private void setFetchFields(String key,String val){
            Map<String,Boolean> fields= (Map<String, Boolean>) this.fetchFields.get(key);
            if (fields == null){
                fields = new HashMap<>();
            }
            fields.put(val,true);
            this.fetchFields.put(key,fields);
        }

        public USERROLE build(){return this;}
    }


    public static class ConditionBuilder{
        private List<Integer> uSERIDList;

        public List<Integer> getUSERIDList(){return this.uSERIDList;}

        private Integer uSERIDSt;

        private Integer uSERIDEd;

        public Integer getUSERIDSt(){return this.uSERIDSt;}

        public Integer getUSERIDEd(){return this.uSERIDEd;}

        private List<Integer> rOLEIDList;

        public List<Integer> getROLEIDList(){return this.rOLEIDList;}

        private Integer rOLEIDSt;

        private Integer rOLEIDEd;

        public Integer getROLEIDSt(){return this.rOLEIDSt;}

        public Integer getROLEIDEd(){return this.rOLEIDEd;}

        private List<String> DESCRIPTIONList;

        public List<String> getDESCRIPTIONList(){return this.DESCRIPTIONList;}


        private List<String> fuzzyDESCRIPTION;

        public List<String> getFuzzyDESCRIPTION(){return this.fuzzyDESCRIPTION;}

        private List<String> rightFuzzyDESCRIPTION;

        public List<String> getRightFuzzyDESCRIPTION(){return this.rightFuzzyDESCRIPTION;}

        public ConditionBuilder uSERIDBetWeen(Integer uSERIDSt,Integer uSERIDEd){
            this.uSERIDSt = uSERIDSt;
            this.uSERIDEd = uSERIDEd;
            return this;
        }

        public ConditionBuilder uSERIDGreaterEqThan(Integer uSERIDSt){
            this.uSERIDSt = uSERIDSt;
            return this;
        }
        public ConditionBuilder uSERIDLessEqThan(Integer uSERIDEd){
            this.uSERIDEd = uSERIDEd;
            return this;
        }


        public ConditionBuilder uSERIDList(Integer ... uSERID){
            this.uSERIDList = solveNullList(uSERID);
            return this;
        }

        public ConditionBuilder uSERIDList(List<Integer> uSERID){
            this.uSERIDList = uSERID;
            return this;
        }

        public ConditionBuilder rOLEIDBetWeen(Integer rOLEIDSt,Integer rOLEIDEd){
            this.rOLEIDSt = rOLEIDSt;
            this.rOLEIDEd = rOLEIDEd;
            return this;
        }

        public ConditionBuilder rOLEIDGreaterEqThan(Integer rOLEIDSt){
            this.rOLEIDSt = rOLEIDSt;
            return this;
        }
        public ConditionBuilder rOLEIDLessEqThan(Integer rOLEIDEd){
            this.rOLEIDEd = rOLEIDEd;
            return this;
        }


        public ConditionBuilder rOLEIDList(Integer ... rOLEID){
            this.rOLEIDList = solveNullList(rOLEID);
            return this;
        }

        public ConditionBuilder rOLEIDList(List<Integer> rOLEID){
            this.rOLEIDList = rOLEID;
            return this;
        }

        public ConditionBuilder fuzzyDESCRIPTION (List<String> fuzzyDESCRIPTION){
            this.fuzzyDESCRIPTION = fuzzyDESCRIPTION;
            return this;
        }

        public ConditionBuilder fuzzyDESCRIPTION (String ... fuzzyDESCRIPTION){
            this.fuzzyDESCRIPTION = solveNullList(fuzzyDESCRIPTION);
            return this;
        }

        public ConditionBuilder rightFuzzyDESCRIPTION (List<String> rightFuzzyDESCRIPTION){
            this.rightFuzzyDESCRIPTION = rightFuzzyDESCRIPTION;
            return this;
        }

        public ConditionBuilder rightFuzzyDESCRIPTION (String ... rightFuzzyDESCRIPTION){
            this.rightFuzzyDESCRIPTION = solveNullList(rightFuzzyDESCRIPTION);
            return this;
        }

        public ConditionBuilder DESCRIPTIONList(String ... DESCRIPTION){
            this.DESCRIPTIONList = solveNullList(DESCRIPTION);
            return this;
        }

        public ConditionBuilder DESCRIPTIONList(List<String> DESCRIPTION){
            this.DESCRIPTIONList = DESCRIPTION;
            return this;
        }

        private <T>List<T> solveNullList(T ... objs){
            if (objs != null){
            List<T> list = new ArrayList<>();
                for (T item : objs){
                    if (item != null){
                        list.add(item);
                    }
                }
                return list;
            }
            return null;
        }

        public ConditionBuilder build(){return this;}
    }

    public static class Builder {

        private USERROLE obj;

        public Builder(){
            this.obj = new USERROLE();
        }

        public Builder uSERID(Integer uSERID){
            this.obj.setUSERID(uSERID);
            return this;
        }
        public Builder rOLEID(Integer rOLEID){
            this.obj.setROLEID(rOLEID);
            return this;
        }
        public Builder DESCRIPTION(String DESCRIPTION){
            this.obj.setDESCRIPTION(DESCRIPTION);
            return this;
        }
        public USERROLE build(){return obj;}
    }

}
